<h3>产品</h3>


<div class="row m-b-10">
  <div class="col-md-4">
    <%= link_to '添加产品', new_product_path, class: 'btn btn-default' if can? :create, Product %>
  </div>
  <div class="col-md-8">
    <%= search_form_for @q, html: {class: 'pull-right form-inline'} do |f| %>
        <div class="form-group">
          <label>名称</label>
          <%= f.search_field :name_cont, class: 'form-control' %>
        </div>
        <%= f.button class: 'btn btn-default' do %>
            <i class="glyphicon glyphicon-search"></i> 查询
        <% end %>
    <% end %>
  </div>
</div>

<table class="table table-striped table-bordered">
  <thead>
  <tr>
    <th>编号</th>
    <th>名称</th>
    <th>价格(元)</th>
    <th>奖励(%)</th>
    <th>售时间段</th>
    <th>有效期</th>
    <th>操作</th>
  </tr>
  </thead>

  <tbody>
  <% @products.each do |product| %>
      <tr>
        <td><%= product.id %></td>
        <td><%= product.name %></td>
        <td><%= product.price %></td>
        <td><%= product.reward %></td>
        <td><%= product.sale_duration %></td>
        <td><%= product.validity %></td>
        <td>
          <%= link_to '详情', product if can? :read, product %>
          <%= link_to '编辑', edit_product_path(product) if can? :update, product %>
        </td>
      </tr>
  <% end %>
  </tbody>
</table>

<%= render partial: 'shared/paginate', locals: {collection: @products} %>
